<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import colaBill from '@/api/cola/colaBill'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()




const options = reactive({
  id: 'cola_bill',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: colaBill.getList,
  recycleApi: colaBill.getRecycleList,
  add: {
    show: true,
    api: colaBill.save,
    auth: ['cola:order:save']
  },
  edit: {
    show: true,
    api: colaBill.update,
    auth: ['cola:order:update']
  },
  delete: {
    show: true,
    api: colaBill.deletes,
    auth: ['cola:order:delete'],
    realApi: colaBill.realDeletes,
    realAuth: ['cola:order:realDeletes']
  },
  recovery: {
    show: true,
    api: colaBill.recoverys,
    auth: ['cola:order:recovery']
  },
  import: {
    show: true,
    url: 'cola/bill/import',
    templateUrl: 'cola/bill/downloadTemplate',
    auth: ['cola:order:import']
  },
  export: {
    show: true,
    url: 'cola/bill/export',
    auth: ['cola:order:export']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入ID"
    }
  },
  {
    title: "用户id",
    dataIndex: "user_id",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入用户id"
    }
  },
  {
    title: "交易来源",
    dataIndex: "pay_source",
    formType: "select",
    search: true,
    commonRules: {
      required: true,
      message: "请输入交易来源"
    },
    dict: {
      data: [
        {
          label: "个人记账",
          value: "1"
        },
        {
          label: "支付宝",
          value: "2"
        },
        {
          label: "微信",
          value: "3"
        },
        {
          label: "云闪付",
          value: "4"
        },
        {
          label: "抖音",
          value: "5"
        },
        {
          label: "拼多多",
          value: "6"
        },
        {
          label: "美团",
          value: "7"
        }
      ],
      translation: true
    }
  },
  {
    title: "支付时间",
    dataIndex: "pay_time",
    formType: "date",
    search: true,
    showTime: true
  },
  {
    title: "交易分类",
    dataIndex: "trade_cate_id",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入交易分类"
    }
  },
  {
    title: "交易对方",
    dataIndex: "counterparty",
    formType: "input",
    search: true
  },
  {
    title: "交易对方账号",
    dataIndex: "counterparty_account",
    formType: "input",
    search: true
  },
  {
    title: "商品说明",
    dataIndex: "goods",
    formType: "input",
    search: true
  },
  {
    title: "收支类型",
    dataIndex: "cash_flow",
    formType: "select",
    search: true,
    commonRules: {
      required: true,
      message: "请输入收支类型"
    },
    dict: {
      data: [
        {
          label: "收入",
          value: "1"
        },
        {
          label: "支出",
          value: "2"
        },
        {
          label: "不计入支出",
          value: "3"
        }
      ],
      translation: true
    }
  },
  {
    title: "交易金额",
    dataIndex: "money",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入交易金额"
    }
  },
  {
    title: "收/付款方式",
    dataIndex: "payment_method",
    formType: "input",
    search: true
  },
  {
    title: "交易状态",
    dataIndex: "trade_status",
    formType: "input",
    search: true
  },
  {
    title: "交易单号",
    dataIndex: "trade_sn",
    formType: "input",
    search: true
  },
  {
    title: "交易商户单号",
    dataIndex: "trade_store_sn",
    formType: "input",
    search: true
  },
  {
    title: "备注",
    dataIndex: "remark",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "修改时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  }
])
</script>
<script> export default { name: 'cola:order' } </script>